/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

/**
 *
 * @author Vasa
 */
public class KolejDTO {

  private Long id;
  private String nazev;
  private String telefon;
  private int kapacita;
  private String ulice;
  private String mesto;
  private String psc;

  public Long getId () {

    return this.id;
  }

  public KolejDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

  public String getNazev() {
     return nazev;
  }

    public void setNazev(String nazev) {
        this.nazev = nazev;
    }

    public int getKapacita() {
        return kapacita;
    }

    public void setKapacita(int kapacita) {
        this.kapacita = kapacita;
    }

    public String getMesto() {
        return mesto;
    }

    public void setMesto(String mesto) {
        this.mesto = mesto;
    }

    public String getPsc() {
        return psc;
    }

    public void setPsc(String psc) {
        this.psc = psc;
    }

    public String getTelefon() {
        return telefon;
    }

    public void setTelefon(String telefon) {
        this.telefon = telefon;
    }

    public String getUlice() {
        return ulice;
    }

    public void setUlice(String ulice) {
        this.ulice = ulice;
    }  

  @Override
  public boolean equals ( final Object rhs ) {

    if ( this == rhs ) return true;

    if ( rhs == null ) return false;

    if ( this.getClass () != rhs.getClass () ) return false;

    final KolejDTO c = (KolejDTO) rhs;

    return this.id == null ? c.id == null : this.id.equals ( c.id ) &&
        this.telefon == null ? c.telefon == null : this.telefon.equals ( c.telefon ) &&
        this.nazev == null ? c.nazev == null : this.nazev.equals ( c.nazev ) &&
        this.ulice == null ? c.ulice == null : this.ulice.equals ( c.ulice ) &&
        this.mesto == null ? c.mesto == null : this.mesto.equals ( c.mesto ) &&
        this.psc == null ? c.psc == null : this.psc.equals ( c.psc ) &&
        this.kapacita == c.kapacita;
    
  }

  @Override
  public int hashCode () {

    final int[] hashCodes = {
        (this.id == null) ? 0 : this.id.hashCode (),
        (this.telefon == null) ? 0 : this.telefon.hashCode (),
        (this.nazev == null) ? 0 : this.nazev.hashCode (),
        (this.ulice == null) ? 0 : this.ulice.hashCode (),
        (this.mesto == null) ? 0 : this.mesto.hashCode (),
        (this.psc == null) ? 0 : this.psc.hashCode (),
        this.kapacita,
    };

    int hash = 17;
    for ( final int currentHashCode: hashCodes ) {

      hash = hash * 31 + currentHashCode;
    }

    return hash;
  }

  @Override
  public Object clone () {

    try {

      return ( (KolejDTO) super.clone () ).setId ( this.id );
    } catch ( CloneNotSupportedException ex ) {

      assert false: "CloneNotSupportedException thrown";
      return null;
    }
  }

  @Override
  public String toString () {

    return this.id + ": " + this.nazev + " " + this.ulice
        + " " + this.mesto + " " + this.psc + " (" + this.kapacita+")"
    ;
  }

  /**
   * Determine whether the person has set necessary information
   */
  public void checkState () {

    final boolean noNazev = this.nazev == null || this.nazev.isEmpty ();

    if ( noNazev )  {

      throw new IllegalStateException ( "Nazev musi byt nastaven" );
    }
  }
}